﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using WorldGoldenPrice;
using WorldIndexInfo;
using WorldExchange;
using System.Threading;
using SJCGoldenPrice;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            WorldIndex_Factory WF = new WorldIndex_Factory();
            WF.writeToDB(ConfigurationSettings.AppSettings["ClassWordIndex"].ToString().Trim());
        }

        private void button1_Click(object sender, EventArgs e)
        {
            GetGold();
        }

        private static void GetGold()
        {
            GoldenPrice_Factory EF = new GoldenPrice_Factory();
            while(true){
            EF.writeToDB(ConfigurationSettings.AppSettings["ClassProduct"].ToString().Trim());
            Thread.Sleep(5000);
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Exchange_Factory EF = new Exchange_Factory();
            EF.writeToDB(ConfigurationSettings.AppSettings["ClassExChange"].ToString().Trim());
        }

        private void button4_Click(object sender, EventArgs e)
        {
       
            while (true)
            {
                //if (DateTime.Now < new DateTime(2013, 2, 24))
                //    return;
                //int RoleWrite = DatabaseService.AccessDB.CheckRoleWrite();
                //if (RoleWrite == 1)
                //{
                    GoldenPrice_Factory EF = new GoldenPrice_Factory();
                    EF.writeToDB(ConfigurationSettings.AppSettings["ClassProduct"].ToString().Trim());
                    DatabaseService.AccessDB.UpdateVGBProfile();
              // }
                
                Thread.Sleep(6 * 1000);
            }
           
        

        }

        private void button5_Click(object sender, EventArgs e)
        {
            SJC_Factory EF = new SJC_Factory();
            EF.writeToDB(ConfigurationSettings.AppSettings["ClassSJC"].ToString().Trim());
            DatabaseService.AccessDB.UpdateVGBProfile();
        }
    }
}
